package com.fable.sp.core.config;

import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.context.request.WebRequest;

/**
 * .
 *
 * @author stormning on 16/9/9.
 */
@ControllerAdvice
public class GlobalBindingInitalizer {
    @InitBinder
    public void registerCustomEditors(WebDataBinder binder, WebRequest request) {
        binder.registerCustomEditor(double.class, new CustomWebBindingInitializer.DoubleEditor());
        binder.registerCustomEditor(Double.class, new CustomWebBindingInitializer.DoubleEditor(true));
        binder.registerCustomEditor(long.class, new CustomWebBindingInitializer.LongEditor());
        binder.registerCustomEditor(Long.class, new CustomWebBindingInitializer.LongEditor(true));
        binder.registerCustomEditor(int.class, new CustomWebBindingInitializer.IntegerEditor());
        binder.registerCustomEditor(Integer.class, new CustomWebBindingInitializer.IntegerEditor(true));
        binder.registerCustomEditor(float.class, new CustomWebBindingInitializer.FloatEditor());
        binder.registerCustomEditor(Float.class, new CustomWebBindingInitializer.FloatEditor(true));
    }
}
